package com.ruoyi.web.controller.agoniappWeb;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.pojo.entity.Activity;
import com.ruoyi.system.service.IAgoniActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pages/activity")
public class ActivityWebController {
    @Autowired
    private IAgoniActivityService agoniActivityService;

    @GetMapping("/listActivities")
    public AjaxResult listActivities() {
        return AjaxResult.success(agoniActivityService.listActivities());
    }

    @GetMapping("/getActivitiesByFacilityId/{facilityId}")
    public AjaxResult getActivitiesByFacilityId(@PathVariable Long facilityId) {
        return AjaxResult.success(agoniActivityService.getActivitiesByFacilityId(facilityId));
    }


    /**
     * TODO: 新增活动
     */
    @PostMapping("/addActivity")
    public AjaxResult addActivity(@RequestBody Activity activity) {
        int result = agoniActivityService.addActivity(activity);
        if (result == 1) {
            return AjaxResult.success("新增活动成功");
        }
        return AjaxResult.error("新增活动失败");
    }



}
